//
//  StatuesFootView.swift
//  swift-GWYWeiBo
//
//  Created by x on 2017/6/2.
//  Copyright © 2017年 HLB. All rights reserved.
//

import UIKit

class StatuesFootView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        //初始化
        setupUI()
    }
    func setupUI() -> Void {
        translatesAutoresizingMaskIntoConstraints = false
        backgroundColor = UIColor(white: 0.2, alpha: 0.5)
        //1.添加子控件
        addSubview(retweetBtu)
        addSubview(commentBtu)
        addSubview(unlikeBtu)
        //2.布局子控
        //2.1转发按钮添加约束
        addConstraint(NSLayoutConstraint.init(item: retweetBtu, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.left, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: retweetBtu, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.height, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: retweetBtu, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.top, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: retweetBtu, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1.0, constant: WIDTH/3))
        //2.2评论按钮添加约束
        addConstraint(NSLayoutConstraint.init(item: commentBtu, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: retweetBtu, attribute: NSLayoutAttribute.right, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: commentBtu, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: retweetBtu, attribute: NSLayoutAttribute.width, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: commentBtu, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: retweetBtu, attribute: NSLayoutAttribute.height, multiplier: 1.0, constant: 0));
        addConstraint(NSLayoutConstraint.init(item: commentBtu, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: retweetBtu, attribute: NSLayoutAttribute.top, multiplier: 1.0, constant: 0))
        //2.3点赞按钮添加约束
        addConstraint(NSLayoutConstraint.init(item: unlikeBtu, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: commentBtu, attribute: NSLayoutAttribute.right, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: unlikeBtu, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: commentBtu, attribute: NSLayoutAttribute.top, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: unlikeBtu, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: commentBtu, attribute: NSLayoutAttribute.width, multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint.init(item: unlikeBtu, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: commentBtu, attribute: NSLayoutAttribute.height, multiplier: 1.0, constant: 0))
    }
    //MARK: -- 懒加载
    //转发按钮
    private lazy var retweetBtu = UIButton.creatButton(btuImage: "timeline_icon_retweet", btuTilte: "转发")
    //评论
    private lazy var commentBtu = UIButton.creatButton(btuImage: "timeline_icon_comment", btuTilte: "评论")
    //赞
    private lazy var unlikeBtu = UIButton.creatButton(btuImage: "timeline_icon_unlike", btuTilte: "赞")

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
